package main

import (
	"fmt"
	"strings"
)

func Parse() {
	data := `398f117b5b5d97d3, started, etcd-001, https://10.0.12.76:2380, https://10.0.12.76:2379
b4e94c95af416c4f, started, etcd-002, https://10.0.12.77:2380, https://10.0.12.77:2379
f502a2fdbf5d9473, started, etcd-003, https://10.0.12.78:2380, https://10.0.12.78:2379
`
	var etcdInfos []etcdInfo
	// 将数据按行分割
	lines := strings.Split(data, "\n") // 跳过表头

	// 遍历每一行，提取所需信息
	for _, line := range lines {
		fruits := strings.Split(line, ",")
		id := fruits[0]
		status := fruits[1]
		name := fruits[2]
		peerAddrs := fruits[3]
		clientAddrs := fruits[4]
		etcdInfos = append(etcdInfos, etcdInfo{
			id:          fruits[0],
			status:      fruits[1],
			name:        fruits[2],
			peerAddrs:   fruits[3],
			clientAddrs: fruits[4],
		})
		fmt.Printf("ID: %s, Status: %s, Name: %s, Peer Addrs: %s, Client Addrs: %s", id, status, name, peerAddrs, clientAddrs)
	}
	fmt.Println(etcdInfos)
}
